ajax('/admin/user/info', function (data) {
    if (data.code == 200) {
        document.querySelector('.user_info span').innerHTML = '欢迎：' + data.data.nickname
        document.querySelector('.user_info img').src = data.data.userPic
        document.querySelector('.user_center_link img').src = data.data.userPic
    }

})
document.querySelector('.logout').onclick = function () {
    if (confirm('退出登录吗！')) {
        localStorage.removeItem('token')
        location.href = 'login.html'
    }
}
document.querySelectorAll('.level01').forEach(function (level01) {
    level01.addEventListener('click', function (even) {
        document.querySelectorAll('.level01').forEach(function (item) {
            item.classList.remove('active')
        })
        this.classList.add('active')
        if (document.querySelectorAll('.level01')[1].className.indexOf('active') !== -1) {
            document.querySelectorAll('.level02 li').forEach(function (lis) {
                lis.addEventListener('click', function () {
                    document.querySelectorAll('.level02 li').forEach(function (li) {
                        li.classList.remove('active')
                    })
                    this.classList.add('active')
                })
            })
        }
        if (this.nextElementSibling.className == 'level02') {
            if (getComputedStyle(this.nextElementSibling).display == 'none') {
                this.nextElementSibling.style.display = 'block'
            } else {
                this.nextElementSibling.style.display = 'none'
            }
        }
    })
})